﻿using System;
using System.Web.Mvc;

namespace Caramel.Web.Mvc.Validation
{
	public class ModelValidatorConfiguration
	{
		public ModelValidatorConfiguration()
		{
			this.FluentValidation = new FluentModelValidatorContainer();
			this.AutoValidation = new AutoModelValidatorContainer();
		}

		public FluentModelValidatorContainer FluentValidation { get; private set; }

		public AutoModelValidatorContainer AutoValidation { get; private set; }

		public ModelValidatorConfiguration Validator(Action<ModelValidatorConfiguration> validation)
		{
			validation(this);

			return this;
		}

		public ModelValidatorProvider BuildModelValidatorProvider()
		{
			return
				new FluentModelValidatorProvider(
					this.FluentValidation,
					this.AutoValidation
				);
		}
	}
}
